package com.woyou.bean;

import java.util.ArrayList;
import java.util.List;

import com.woyou.ui.api.CountSize;

/**
 * OptionGroup类型说明
 * 
 * @author 荣
 * 
 */
public class OptionGroup extends SuperBean implements CountSize{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 属性组名称
	 */
	private String optGName;
	/**
	 * 属性组Id
	 */
	private String optGId;
	/**
	 * 属性Option列表
	 */
	private List<Option> optList = new ArrayList<Option>();
	/**
	 * M选N的N,(选几个)
	 */
	private int selectNum;
	/**
	 * 是否必选
	 */
	private boolean required;
	/**
	 * 是否满足结算条件
	 */
//	private boolean meet = false;
	
	/**
	 * 选中的Option列表
	 */
//	private List<Option> chosenList = new ArrayList<Option>();
//	public List<Option> getChosenList() {
//		return chosenList;
//	}

	/**
	 * 控制选中Opt的函数
	 * @param opt
	 */
//	public Option changeOpt(Option opt){
//		Option remove = null;
//		boolean contains = chosenList.contains(opt);
//		if( contains ){
//			//opt取消选中
//			chosenList.remove(opt);
//			remove = opt;
//			opt.setChecked(false);
//		}else{
//			//选中opt
//			int size = chosenList.size();
//			if( size < selectNum ){
//				chosenList.add(opt);
//				
//			}else{
//				if(chosenList.size()>0){
//					remove = chosenList.remove(0);
//					remove.setChecked(false);
//					chosenList.add(opt);
//				}
//			}
//			opt.setChecked(true);
//		}
//		
//		if( chosenList.size() == selectNum || !required){
//			meet = true;
//		}else{
//			meet = false;
//		}
//		return remove;
//	}

	public String getOptGName() {
		return optGName;
	}

	public void setOptGName(String optGName) {
		this.optGName = optGName;
	}

	public String getOptGId() {
		return optGId;
	}

	public void setOptGId(String optGId) {
		this.optGId = optGId;
	}

	public List<Option> getOptList() {
		if(optList == null){
			optList = new ArrayList<Option>();
		}
		return optList;
	}

	public void setOptList(ArrayList<Option> optList) {
		this.optList = optList;
	}

	public int getSelectNum() {
		return selectNum;
	}

	public void setSelectNum(int selectNum) {
		this.selectNum = selectNum;
	}

	public boolean isRequired() {
		return required;
	}

	public void setRequired(boolean required) {
		this.required = required;
	}
	
//	public boolean isMeet() {
//		return meet;
//	}
//
//	public void setMeet(boolean meet) {
//		this.meet = meet;
//	}

	@Override
	public String toString() {
		return "OptionGroup [optGName=" + optGName + ", optGId=" + optGId
				+ ", optList=" + optList + ", selectNum=" + selectNum
				+ ", required=" + required + "]";
	}

	@Override
	public int getSize() {
		if( optList == null ){
			return 0;
		}
		return optList.size();
	}

}
